<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="id" prop="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商店id">
            <el-input v-model="form.shopId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="类型 1001==便利店 1002==烟酒店 103==奶茶店">
            <el-input v-model="form.category" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="主要经营类型">
            <el-input v-model="form.type" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="店铺名称">
            <el-input v-model="form.name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="省">
            <el-input v-model="form.province" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="区">
            <el-input v-model="form.county" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="详情地址">
            <el-input v-model="form.detialAddress" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="完成地址">
            <el-input v-model="form.address" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="门脸照片">
            <el-input v-model="form.facePhoto" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="logo图片">
            <el-input v-model="form.logoPhoto" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商家折扣">
            <el-input v-model="form.discount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单金额">
            <el-input v-model="form.amount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="优惠金额">
            <el-input v-model="form.discountAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="实付金额">
            <el-input v-model="form.payAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="呷币余额">
            <el-input v-model="form.xbBalance" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="订单支付状态">
            <el-input v-model="form.orderStatus" style="width: 370px;" />
          </el-form-item>

          <el-form-item label="订单来源">
            <el-input v-model="form.orderInfo" style="width: 370px;" />
          </el-form-item>

          <el-form-item label="消费呷币">
            <el-input v-model="form.consumeXb" style="width: 370px;" />
          </el-form-item>

          <el-form-item label="创建时间">
            <el-input v-model="form.createTimes" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="修改时间">
            <el-input v-model="form.updateTimes" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('id')" prop="id" label="id" />
        <el-table-column v-if="columns.visible('shopId')" prop="shopId" label="商店id" />
        <el-table-column v-if="columns.visible('category')" prop="category" label="类型" >
          <template slot-scope="scope">
            {{ dict.label.category[scope.row.category]}}
          </template>
        </el-table-column>
        <el-table-column width="100px" v-if="columns.visible('type')" prop="type" label="主要经营类型" />
        <el-table-column v-if="columns.visible('name')" prop="name" label="店铺名称" />
        <el-table-column v-if="columns.visible('province')" prop="province" label="省" />
        <el-table-column v-if="columns.visible('city')" prop="city" label="市" />
        <el-table-column v-if="columns.visible('county')" prop="county" label="区" />
        <el-table-column v-if="columns.visible('detialAddress')" prop="detialAddress" label="详情地址" />
        <el-table-column v-if="columns.visible('address')" prop="address" label="完成地址" />
        <el-table-column v-if="columns.visible('facePhoto')" prop="facePhoto" label="门脸照片" />
        <el-table-column v-if="columns.visible('logoPhoto')" prop="logoPhoto" label="logo图片" />
        <el-table-column v-if="columns.visible('discount')" prop="discount" label="商家折扣" />
        <el-table-column v-if="columns.visible('amount')" prop="amount" label="订单金额" />
        <el-table-column v-if="columns.visible('discountAmount')" prop="discountAmount" label="优惠金额" />
        <el-table-column v-if="columns.visible('payAmount')" prop="payAmount" label="实付金额" />
        <el-table-column v-if="columns.visible('xbBalance')" prop="xbBalance" label="呷币余额" />
        <el-table-column width="100px" v-if="columns.visible('orderStatus')" prop="orderStatus" label="订单支付状态" >
          <template slot-scope="scope">
            {{ dict.label.order_status[scope.row.orderStatus]}}
          </template>
        </el-table-column>
        <el-table-column width="100px" v-if="columns.visible('orderInfo')" prop="orderInfo" label="订单来源" />
        <el-table-column width="100px" v-if="columns.visible('consumeXb')" prop="consumeXb" label="消费呷币" />

        <el-table-column width="150px" v-if="columns.visible('createTimes')" prop="createTimes" label="创建时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTimes) }}</span>
          </template>
        </el-table-column>
        <el-table-column width="150px" v-if="columns.visible('updateTimes')" prop="updateTimes" label="修改时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTimes) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-permission="['admin','shopStoreOrder:edit','shopStoreOrder:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudShopStoreOrder from '@/api/shopStoreOrder'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import MaterialList from "@/components/material";

// crud交由presenter持有
const defaultCrud = CRUD({ title: '商户订单信息', url: 'api/shopStoreOrder', sort: 'id,desc', crudMethod: { ...crudShopStoreOrder }})
const defaultForm = { id: null, shopId: null, category: null, type: null, name: null, province: null, city: null, county: null, detialAddress: null, address: null, facePhoto: null, logoPhoto: null, discount: null, amount: null, discountAmount: null, payAmount: null, xbBalance: null,orderStatus:null,orderInfo: null,consumeXb: null, createTimes: null, updateTimes: null }
export default {
  name: 'ShopStoreOrder',
  components: { pagination, crudOperation, rrOperation, udOperation ,MaterialList},
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  dicts: ['category','order_status'],
  data() {
    return {

      permission: {
        add: ['admin', 'shopStoreOrder:add'],
        edit: ['admin', 'shopStoreOrder:edit'],
        del: ['admin', 'shopStoreOrder:del']
      },
      rules: {
        id: [
          { required: true, message: '不能为空', trigger: 'blur' }
        ]
      }    }
  },
  watch: {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
  }
}



</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
</style>
